package com.yay.mashiro.yayclient.ui.clickgui.panel;

import java.awt.Color;

import com.yay.mashiro.yayclient.Yay;
import com.yay.mashiro.yayclient.module.modules.render.ClickGui;
import com.yay.mashiro.yayclient.ui.clickgui.font.HanabiFonts;
import com.yay.mashiro.yayclient.ui.clickgui.font.UnicodeFontRenderer;
import com.yay.mashiro.yayclient.utils.PlayerUtils;

import ClassSub.Class246;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;

public class CategoryPanel {
	float x;
    float y;
    float radius;
    String logo;
    public String title;
    ScaledResolution sr;
    public Boolean active = false;
    double state = 0.0;
    //sidebar
    SideBar sb;

    public CategoryPanel(float f, float f2, float f3, String string, ScaledResolution scaledResolution, SideBar class33) {
        this.x = f;
        this.y = f2;
        this.radius = f3;
        this.title = string;
        this.sr = scaledResolution;
        this.sb = class33;
        this.logo = string.equals("Combat") ? HanabiFonts.ICON_CLICKGUI_COMBAT : (string.equals("Movement") ? HanabiFonts.ICON_CLICKGUI_MOVEMENT : (string.equals("Render") ? HanabiFonts.ICON_CLICKGUI_RENDER : (string.equals("Player") ? HanabiFonts.ICON_CLICKGUI_PLAYER : (string.equals("World") ? HanabiFonts.ICON_CLICKGUI_WORLD : HanabiFonts.ICON_CLICKGUI_GHOST))));
    }

	public void drawButton() {
        this.sr = new ScaledResolution(Minecraft.getMinecraft());
        if (this.active.booleanValue()) {
            this.state = this.getAnimationState(this.state, 5.0, 35.0);
            Class246.drawRoundedRect((int)this.x - 45, (int)this.y - 16, (int)this.x + 45, (int)this.y + 17, 15.0f, ClickGui.theme.isCurrentMode("Light") ? new Color(-14848033).brighter().getRGB() : new Color(47, 116, 253).getRGB());
        }
    }

    public void drawOther() {
    	
    	this.sr = new ScaledResolution(Minecraft.getMinecraft());
        UnicodeFontRenderer unicodeFontRenderer = Yay.getFontManager().icon20;
        UnicodeFontRenderer unicodeFontRenderer2 = Yay.getFontManager().raleway20;
        if (this.sr.getScaledHeight() < 330) {
            unicodeFontRenderer = Yay.getFontManager().icon25;
            unicodeFontRenderer2 = Yay.getFontManager().raleway12;
            
        } else {
        	
            unicodeFontRenderer = Yay.getFontManager().icon40;
            unicodeFontRenderer2 = Yay.getFontManager().raleway17;
        }
        if (ClickGui.theme.isCurrentMode("Light")) {
            unicodeFontRenderer.drawString(this.logo, this.x - this.radius / 2.0f, this.y - unicodeFontRenderer.getStringHeight(this.logo) / 2.0f, this.active != false ? new Color(255, 255, 255).getRGB() : new Color(-14848033).brighter().getRGB());
            unicodeFontRenderer2.drawString(this.title, this.x - (float)(unicodeFontRenderer.getStringWidth(this.logo) / 2), this.y - unicodeFontRenderer2.getStringHeight(this.title) / 2.0f, this.active != false ? new Color(255, 255, 255).getRGB() : new Color(-14848033).brighter().getRGB());
        } else {

            unicodeFontRenderer.drawString(this.logo, this.x - this.radius / 2.0f, this.y - unicodeFontRenderer.getStringHeight(this.logo) / 2.0f, this.active != false ? new Color(255, 255, 255).getRGB() : new Color(47, 116, 253).getRGB());
            unicodeFontRenderer2.drawString(this.title, this.x - (float)(unicodeFontRenderer.getStringWidth(this.logo) / 2), this.y - unicodeFontRenderer2.getStringHeight(this.title) / 2.0f, this.active != false ? new Color(255, 255, 255).getRGB() : new Color(47, 116, 253).getRGB());
        }
    }

    public void onPress() {
        for (CategoryPanel class81 : this.sb.button) {
            class81.active = false;
        }
        this.active = true;
        this.state = 0.0;
    }

    public boolean isPressed(int n, int n2) {
        return (this.isHovering(n, n2, (double)this.x - (double)this.radius / 1.5, (double)this.y - (double)this.radius / 3.5, (double)this.x + (double)this.radius / 1.5, (double)this.y + (double)this.radius / 3.5) && this.active == false ? 1 : 0) != 0;
    }

    private boolean isHovering(int n, int n2, double d, double d2, double d3, double d4) {
        return ((double)n > d && (double)n < d3 && (double)n2 > d2 && (double)n2 < d4 ? 1 : 0) != 0;
    }

    public double getAnimationState(double d, double d2, double d3) {
        float f = (float)((double)Class246.delta * d3);
        d = d < d2 ? (d + (double)f < d2 ? (d += (double)f) : d2) : (d - (double)f > d2 ? (d -= (double)f) : d2);
        return d;
    }
}
